<template>
	<view>
		<view class="video-list">
			<view class="video-content" v-for="(item, ind) in device" :key="ind">
				<!-- <view class="video-cover">
					<image :src="item.picUrl" mode="aspectFill"></image>
				</view> -->
				<view class="video-describe">
					<view style="width: 80%;">
						<view class="video-tit">
							设备名称:{{item.machineName}}
						</view>
						<view class="video-reader">
							设备代码:{{item.deviceCode}}
						</view>
					</view>
					<view>
						<view @click="select(item)" class="iconfont icon-set" style="color: #161616;font-size: 32rpx;margin-top: 15rpx;">
							<text style="margin-left: 10rpx;font-size: 26rpx;color: #4a4a4a;">设置</text>
						</view>
					</view>
					<!-- <view class="checkMore" @click="detail(item)">
						<text>查看详情</text>
					</view> -->
				</view>
			</view>
		</view>
		<view class="afrim" @click="addMeal()">添加设备</view>
		<uni-popup ref="doorpopup" :mask-click="false" type="center">
			<view class="unipopup">
				<view class="buttomopendoor1" @click="detail()"><text>绑定套餐</text></view>
				<view class="buttomopendoor2" @click="updateMeal()"><text>编辑设备</text></view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import Api from '@/common/api';
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	import '@/static/icon/iconfont.css';
	export default {
		components: {
			uniPopup
		},
		data() {
			return {
				index: 0,
				device:[],
				storeId:null,
				currentDevice:null
			}
		},
		onShow() {
			this.getDevices();
		},
		onLoad(options) {
			this.storeId = options.storeId;
			console.log('1111'+this.storeId)
			this.getDevices();
		},
		methods: {
			async getDevices(){
				let params = {
					storeId:this.storeId
				}
				let data = await Api.apiCall('get', Api.qsg.getDevices, params);
				if(data){
					this.device = data
				}
			},
			select(item){
				this.currentDevice = item;
				this.$refs.doorpopup.open('center')
			},
			detail() {
				this.$refs.doorpopup.close()
				let deviceId = this.currentDevice.id;
				uni.navigateTo({
					url:'/pages/device/mealindex?deviceId='+deviceId+'&storeId='+this.storeId
				})
			},
			addMeal() {
				uni.navigateTo({
					url:'/pages/device/edit?storeId='+this.storeId
				})
			},
			updateMeal(item){
				this.$refs.doorpopup.close()
				let deviceId = this.currentDevice.id;
				uni.navigateTo({
					url:'/pages/device/edit?deviceId='+deviceId+'&storeId='+this.storeId
				})
			}
		}
	}
</script>

<style>
	.afrim{
		width: 200rpx;
		height: 80rpx;
		background: #0DA944;
		border-radius: 30rpx;
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 80rpx;
		text-align: center;
		position: fixed;
		bottom: calc(100% - 95%);
		margin-left: 340rpx;
	}
	.priceSign{
		font-size: 24rpx;
	}
	.priceNum{
		font-size: 32rpx;
		font-weight: bold;
	}
	.priceIcon{
		font-size: 24rpx;
	}
	.schoolName{
		width: 750rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		font-size: 50rpx;
		font-weight: bold;
		color: #000000;
	}
	.uni-input{
		padding: 0 24rpx;
	}
	.choese{
		width: 750rpx;
		display: flex;
		box-sizing: border-box;
		padding:0 30rpx;
		color: #888888;
	}
	.dataName{
		height: 60rpx;
	}
	.currentSchool{
		height: 60rpx;
		background: #FFFFFF;
	}
	.video-tit {
		font-size: 30rpx;
		color: #62b074;
		font-weight: bold;
		display: inline-block;
		vertical-align: top;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}
	
	.checkMore text{
		display: block;
		width: 100%;
		height: 60rpx;
		line-height: 58rpx;
		font-size: 24rpx;
		color: #172a89;
		border: 1px solid #172A89;
		text-align: center;
		box-sizing: border-box;
		margin-top: 46rpx;
		border-radius: 50rpx;
	}
	
	.checkMore {
		font-size: 24rpx;
		color: #172a89;
		flex: 1;
	}
	
	.buttomopendoor1 {
		width: 400rpx;
		height: 80rpx;
		background: #E3F6E4;
		border: 1px solid #B8E6BA;
		border-radius: 40rpx;
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #0DA944;
		line-height: 80rpx;
		text-align: center;
		margin-top: 60rpx;
	}
	
	.buttomopendoor2 {
		width: 400rpx;
		height: 80rpx;
		background: #0DA944;
		border-radius: 40rpx;
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 80rpx;
		text-align: center;
		margin-top: 24rpx;
	}
	
	.unipopup {
		height: 300rpx;
		width: 480rpx;
		background-color: #FFFFFF;
		display: flex;
		flex-direction: column;
		align-items: center;
		border-radius: 24rpx;
	}
	
	.video-price {
		font-size: 30rpx;
		color: #666;
		overflow: hidden;
		display: inline-block;
		vertical-align: top;
		text-align: center;
		box-sizing: border-box;
	}
	
	.video-reader {
		font-size: 24rpx;
		color: #666;
	}
	
	.video-describe {
		display: inline-block;
		vertical-align: top;
		display: flex;
		width: 100%;
		padding-left: 20rpx;
	}
	
	.video-cover {
		width: 100rpx;
		height: 100rpx;
		margin: 30rpx 30rpx 30rpx 0;
		display: inline-block;
		vertical-align: top;
		border-radius: 50%;
		flex: 1;
	}
	
	.video-cover image {
		width: 100rpx;
		height: 100rpx;
		background: #FFFFFF;
		border-radius: 50%;
	}
	
	.video-content {
		width: 690rpx;
		padding: 22rpx 0;
		border: 1rpx solid #f1f1f1;
		box-shadow: 0 0 10px #e6e6e6;
		border-radius: 20rpx;
		box-sizing: border-box;
		display: flex;
		margin-top: 20rpx;
	}
	
	.video-content:last-child {
		border: none;
	}
	
	.video-list {
		width: 750rpx;
		height: auto;
		padding: 0 30rpx;
		box-sizing: border-box;
	}
</style>
